local fdir_table = {
   {  1,  0 },
   {  0, -1 },
   { -1,  0 },
   {  0,  1 },
   {  1,  0 },
   {  0, -1 },
   { -1,  0 },
   {  0,  1 },
}

function furniture.curtain_placement(pos)
   local node = minetest.get_node(pos)
   local nodename = node.name
   local fdir = node.param2
   local posr = {x = pos.x + fdir_table[fdir+1][1], y=pos.y, z = pos.z + fdir_table[fdir+1][2]}
   local posl = {x = pos.x - fdir_table[fdir+1][1], y=pos.y, z = pos.z - fdir_table[fdir+1][2]}
   local noder = minetest.get_node(posr)
   local nodel = minetest.get_node(posl)
   local nodername = noder.name
   local nodelname = nodel.name

   local height = string.sub(nodename, 19, 19)
   local part = string.sub(nodename, 20, 20)
   local color = string.sub(nodename, 22, -3)

   local rheight = string.sub(nodername, 19, 19)
   local rpart = string.sub(nodername, 20, 20)
   local rcolor = string.sub(nodername, 22, -3)

   local lheight = string.sub(nodelname, 19, 19)
   local lpart = string.sub(nodelname, 20, 20)
   local lcolor = string.sub(nodelname, 22, -3)

   if lheight == height and lcolor == color then --placing to the right
      minetest.set_node(pos,{name = 'furniture:curtain_'..height..'r_'..color..'_1', param2=fdir})
      if lpart == 'r' then
         minetest.set_node(posl,{name = 'furniture:curtain_'..height..'c_'..color..'_1', param2=fdir})
      elseif lpart == 's' then
         minetest.set_node(posl,{name = 'furniture:curtain_'..height..'l_'..color..'_1', param2=fdir})
      end
   end
   if rheight == height and rcolor == color then --placing to the left
      minetest.set_node(pos,{name = 'furniture:curtain_'..height..'l_'..color..'_1', param2=fdir})
      if rpart == 'l' then
         minetest.set_node(posr,{name = 'furniture:curtain_'..height..'c_'..color..'_1', param2=fdir})
      elseif rpart == 's' then
         minetest.set_node(posr,{name = 'furniture:curtain_'..height..'r_'..color..'_1', param2=fdir})
      end
   end
end

function furniture.curtain_removal(pos, node, digger)
   local nodename = node.name
   local fdir = node.param2
   local posr = {x = pos.x + fdir_table[fdir+1][1], y=pos.y, z = pos.z + fdir_table[fdir+1][2]}
   local posl = {x = pos.x - fdir_table[fdir+1][1], y=pos.y, z = pos.z - fdir_table[fdir+1][2]}
   local noder = minetest.get_node(posr)
   local nodel = minetest.get_node(posl)
   local nodername = noder.name
   local nodelname = nodel.name

   local height = string.sub(nodename, 19, 19)
   local part = string.sub(nodename, 20, 20)
   local color = string.sub(nodename, 22, -3)

   local rheight = string.sub(nodername, 19, 19)
   local rpart = string.sub(nodername, 20, 20)
   local rcolor = string.sub(nodername, 22, -3)

   local lheight = string.sub(nodelname, 19, 19)
   local lpart = string.sub(nodelname, 20, 20)
   local lcolor = string.sub(nodelname, 22, -3)
   minetest.remove_node(pos)

   local player_inv = digger:get_inventory()
   if player_inv:room_for_item('player', 'furniture:curtain_'..height..'s_'..color..'_1') then
      player_inv:add_item('player', 'furniture:curtain_'..height..'s_'..color..'_1')
   end

   if lheight == height and lcolor == color then --node to the left
      if lpart == 'c' then
         minetest.set_node(posl,{name = 'furniture:curtain_'..height..'r_'..color..'_1', param2=nodel.param2})
      elseif lpart == 'l' then
         minetest.set_node(posl,{name = 'furniture:curtain_'..height..'s_'..color..'_1', param2=nodel.param2})
      end
   end
   if rheight == height and rcolor == color then --node to the right
      if rpart == 'c' then
         minetest.set_node(posr,{name = 'furniture:curtain_'..height..'l_'..color..'_1', param2=noder.param2})
      elseif rpart == 'r' then
         minetest.set_node(posr,{name = 'furniture:curtain_'..height..'s_'..color..'_1', param2=noder.param2})
      end
   end
end

function furniture.curtain_toggle(pos, node)
   local nodename = node.name
   local height = string.sub(nodename, 19, 19)
   local part = string.sub(nodename, 20, 20)
   local color = string.sub(nodename, 22, -3)
   local state = string.sub(nodename, -1, -1)
   local new_state = math.abs(state - 1) --if state is zero, subtracting 1 makes it negative one, and the absolute value of negative one is one.
   local fdir = node.param2
   local curtain = color..'_'..height
   if fdir == 0 or fdir == 2 then --Search in the X axis
      local next_l_pos = {x=pos.x-1, y=pos.y, z=pos.z}
      local next_l_node = minetest.get_node(next_l_pos).name
      local next_l_color = string.sub(next_l_node, 22, -3)
      local next_l_height = string.sub(next_l_node, 19, 19)
      local next_l_part = string.sub(next_l_node, 20, 20)
      local next_l_curtain = next_l_color..'_'..next_l_height
      local next_r_pos = {x=pos.x+1, y=pos.y, z=pos.z}
      local next_r_node = minetest.get_node(next_r_pos).name
      local next_r_color = string.sub(next_r_node, 22, -3)
      local next_r_height = string.sub(next_r_node, 19, 19)
      local next_r_part = string.sub(next_r_node, 20, 20)
      local next_r_curtain = next_r_color..'_'..next_r_height
      minetest.set_node(pos, {name='furniture:curtain_'..height..part..'_'..color..'_'..new_state, param2 = fdir})
      while next_l_curtain == curtain do
         minetest.set_node(next_l_pos, {name='furniture:curtain_'..height..next_l_part..'_'..color..'_'..new_state, param2 = fdir})
         next_l_pos.x = next_l_pos.x - 1
         next_l_node = minetest.get_node(next_l_pos).name
         next_l_color = string.sub(next_l_node, 22, -3)
         next_l_height = string.sub(next_l_node, 19, 19)
         next_l_part = string.sub(next_l_node, 20, 20)
         next_l_curtain = next_l_color..'_'..next_l_height
      end
      while next_r_curtain == curtain do
         minetest.set_node(next_r_pos, {name='furniture:curtain_'..height..next_r_part..'_'..color..'_'..new_state, param2 = fdir})
         next_r_pos.x = next_r_pos.x + 1
         next_r_node = minetest.get_node(next_r_pos).name
         next_r_color = string.sub(next_r_node, 22, -3)
         next_r_height = string.sub(next_r_node, 19, 19)
         next_r_part = string.sub(next_r_node, 20, 20)
         next_r_curtain = next_r_color..'_'..next_r_height
      end
   elseif fdir == 1 or fdir == 3 then --Search in the Z axis
      local next_l_pos = {x=pos.x, y=pos.y, z=pos.z-1}
      local next_l_node = minetest.get_node(next_l_pos).name
      local next_l_color = string.sub(next_l_node, 22, -3)
      local next_l_height = string.sub(next_l_node, 19, 19)
      local next_l_part = string.sub(next_l_node, 20, 20)
      local next_l_curtain = next_l_color..'_'..next_l_height
      local next_r_pos = {x=pos.x, y=pos.y, z=pos.z+1}
      local next_r_node = minetest.get_node(next_r_pos).name
      local next_r_color = string.sub(next_r_node, 22, -3)
      local next_r_height = string.sub(next_r_node, 19, 19)
      local next_r_part = string.sub(next_r_node, 20, 20)
      local next_r_curtain = next_r_color..'_'..next_r_height
      minetest.set_node(pos, {name='furniture:curtain_'..height..part..'_'..color..'_'..new_state, param2 = fdir})
      while next_l_curtain == curtain do
         minetest.set_node(next_l_pos, {name='furniture:curtain_'..height..next_l_part..'_'..color..'_'..new_state, param2 = fdir})
         next_l_pos.z = next_l_pos.z - 1
         next_l_node = minetest.get_node(next_l_pos).name
         next_l_color = string.sub(next_l_node, 22, -3)
         next_l_height = string.sub(next_l_node, 19, 19)
         next_l_part = string.sub(next_l_node, 20, 20)
         next_l_curtain = next_l_color..'_'..next_l_height
      end
      while next_r_curtain == curtain do
         minetest.set_node(next_r_pos, {name='furniture:curtain_'..height..next_r_part..'_'..color..'_'..new_state, param2 = fdir})
         next_r_pos.z = next_r_pos.z + 1
         next_r_node = minetest.get_node(next_r_pos).name
         next_r_color = string.sub(next_r_node, 22, -3)
         next_r_height = string.sub(next_r_node, 19, 19)
         next_r_part = string.sub(next_r_node, 20, 20)
         next_r_curtain = next_r_color..'_'..next_r_height
      end
   end
end

local dye_table = furniture.dyes

for i in ipairs(dye_table) do
   local name = dye_table[i][1]
   local desc = dye_table[i][2]
   local hex = dye_table[i][3]

   minetest.register_node('furniture:curtain_ss_'..name..'_0', {
      description = 'Short '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_short_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_ss_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_ss_'..name..'_1', {
      description = 'Short '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_short_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_short_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      walkable = false,
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {breakable=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      after_place_node = function(pos, placer, itemstack)
         furniture.curtain_placement(pos)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_sl_'..name..'_0', {
      description = 'Short Left '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_short_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_ss_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_sl_'..name..'_1', {
      description = 'Short Left '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_sl_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_sl_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      walkable = false,
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_ss_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_sr_'..name..'_0', {
      description = 'Short Right '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_short_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_ss_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_sr_'..name..'_1', {
      description = 'Short Right '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_sr_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_sr_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      walkable = false,
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_ss_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_sc_'..name..'_0', {
      description = 'Short Middle '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_short_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_ss_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_sc_'..name..'_1', {
      description = 'Short Middle '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_sc_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_sc_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      walkable = false,
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_ss_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_ts_'..name..'_0', {
      description = 'Tall '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tall_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_tall_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_ts_'..name..'_1', {
      description = 'Tall '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tall_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_tall_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      walkable = false,
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      groups = {breakable=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      after_place_node = function(pos, placer, itemstack)
         furniture.curtain_placement(pos)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_tl_'..name..'_0', {
      description = 'Tall Left '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tall_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_tl_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_tl_'..name..'_1', {
      description = 'Tall Left '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tl_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_tl_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      walkable = false,
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_tl_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_tr_'..name..'_0', {
      description = 'Tall Right '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tall_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_tl_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_tr_'..name..'_1', {
      description = 'Tall Right '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tr_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_tr_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      walkable = false,
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_tl_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_tc_'..name..'_0', {
      description = 'Tall Middle '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tall_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_tl_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

   minetest.register_node('furniture:curtain_tc_'..name..'_1', {
      description = 'Tall Middle '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tc_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_tc_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      walkable = false,
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      drop = 'furniture:curtain_tl_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.5, .4, .5, .5, .5},
         },
      groups = {breakable=1, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         furniture.curtain_toggle(pos, node)
      end,
      on_dig = function(pos, node, digger)
         furniture.curtain_removal(pos, node, digger)
      end
   })

end
